<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>公告</title>

    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/yzl.css"/>

    <style>
        .username-warn {
            font-size: 12px;
            margin: 20px 15px;
        }

        .username-warn > span {
            background-size: 22px 22px;
            background-position: left center;
            background-repeat: no-repeat;
            padding-left: 22px;
        }

        .username-warn > span.big {
            background-image: url(../../image/big/username_icon_warn.png);
        }

        .username-warn > span.small {
            background-image: url(../../image/small/username_icon_warn.png);
        }
    </style>

</head>
<body>
<div id="blank" class="header">
    <div v-back.tapmode class="back"></div>
    <span class="title">验证信息</span>
</div>
<div id="app" class="main-container">
    <div style="background:#ffffff">
      <textarea id="input" v-model="remark"  placeholder="请输入验证信息100字以内" style="width:100%;height:60px;outline: none;padding:15px">

           </textarea>
    </div>
    <a class="btn-commit" style="background:#33375E"  v-myclick="sendrequest" >发送</a>

</div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script>
    var user;
    apiready = function () {
        setBSImg();
        new Vue({
            el: '#blank'
        });
        user = JSON.parse(getPrefs('user'));
        initApp();
        api.parseTapmode();
        addListeners();
    };

    function initApp() {
        var vm = new Vue({
            el: '#app',
            data: {
                remark: api.pageParam.target_type==1?'加个好友，一起养牛赚钱吧~':'我是'+user.nickname+',一起养牛吧',
                BSImg: {
                    big: Vue.BSImg == 'big',
                    small: Vue.BSImg == 'small'
                }
            },
            watch:{
                remark:function (n, o) {
                    this.nameByte = n.replace(/[^\x00-\xff]/g,"xx").length;
                    if(this.nameByte > 100){
                        this.remark = o;
                    }
                }
            },
            methods: {
                sendrequest: function () {

                  var data = {
                      member_id: getPrefs('member_id'),
                      target_id: api.pageParam.target_id,
                      from_type: api.pageParam.from_type,
                      target_type:api.pageParam.target_type,
                      comment:this.remark
                  };
                  var callback = function (ret,err) {
                      api.toast({
                        msg : '请求发送成功'
                      });
                      api.parseTapmode();
                      api.closeWin();
                  };
                  pinet.post(URL.addApply, data, callback);
                },
            },
            mounted:function () {
            }
        });
    }

    function addListeners() {
        api.addEventListener({
            name: 'viewappear'
        }, function () {
            onPageStart();
        });

        api.addEventListener({
            name: 'viewdisappear'
        }, function (ret, err) {
            onPageEnd();
        });

        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            onPageEnd();
            api.closeWin();
        });
    }
</script>
</html>
